﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Drawing;
using System.Drawing.Imaging;

namespace RoyTools.ScreenCapture.Domain
{
    /// <summary>
    /// 屏幕截取类
    /// </summary>
    public class ScreenCapture
    {
        /// <summary>
        /// 默认截取方法
        /// </summary>
        /// <param name="filePath"></param>
        public static void Default(string filePath)
        {
            var screen = Screen.PrimaryScreen;
            var rectangle = screen.Bounds;
            var width = rectangle.Width;
            var height = rectangle.Height;
            using (var image = new Bitmap(width, height))
            {
                using (var graphics = Graphics.FromImage(image))
                {
                    graphics.CopyFromScreen(new Point(0, 0), new Point(0, 0), new Size(width, height));
                    image.Save(filePath, ImageFormat.Jpeg);
                    graphics.Dispose();
                }
                image.Dispose();
            }
        }
    }
}
